import com.thoughtworks.xstream.XStream;

public class XStreamTest {
	public static void main(String[] args)
    {
        Person person=new Person();
        person.setName("独孤求败");
        person.setAge(100);
        XStream xstream = new XStream();
        // 进行注解的检测  如果没有这行注解将不起作用
        xstream.autodetectAnnotations(true); 
        //XML序列化
        String xml = xstream.toXML(person);
        System.out.println(xml);
        //XML反序列化
        Person person1=(Person)xstream.fromXML(xml);
        System.out.println(person1.getName());
        System.out.println(person1.getAge());
    }
}
